﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using Microsoft.Win32;

namespace proyecto
{
    /// <summary>
    /// Lógica de interacción para selectCel.xaml
    /// </summary>
    public partial class selectCel : Window
    {
        private bool selected;

        private string file;

        public selectCel()
        {
            InitializeComponent();
            selected = false;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (listBox1.Items.Count > 0)
            {
                selected = true;
                file = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "/temp/autogeneratedCelList.txt";

                FileStream stream = new FileStream(file, FileMode.OpenOrCreate, FileAccess.Write);

                StreamWriter writer = new StreamWriter(stream);
                //MessageBox.Show(listBox1.Items[0].ToString());
                writer.Write("cel_files");
                for (int i = 0; i < listBox1.Items.Count; i++)
                    writer.WriteLine("\n "+listBox1.Items[i].ToString());

                writer.Close();
                

            }
            this.Close();


        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            Nullable<bool> result = (bool)open.ShowDialog();
            if (result==true)
            {
                listBox1.Items.Add(open.FileName);
            }
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        public bool getSelected()
        {
            return selected;
        }

        public string getCelList()
        {
            return file;
        }
    }
}
